#ifndef CSBALLFM_H
#define CSBALLFM_H

#include <QWidget>
#include <QtGui>
#include "ball.h"
#include "itemmdl.h"
#include "ballmdl.h"

struct SBounds
{
    int x, y, w, h;
};

class SCustomBallForm : public QWidget
{
    Q_OBJECT

private:
    int FAlpha;
    int timerId;

    int mx, my;
    int omx, omy;
    int gmx, gmy;
//    int vmx, vmy;
    bool capt;
    bool moved;
    bool closing;

    int lastx, lasty;

protected slots:
    virtual void PaintBack(QImage *img);

protected:
    SBall *Ball;
    SItemModel *ItemModel;

    int vmx, vmy;

    virtual void setFrame(QRect frame);
//    virtual void setPosition(int x, int y);
//    virtual void setSize(int a, int b);

    virtual void mousePressEvent(QMouseEvent *mouse);
    virtual void mouseMoveEvent(QMouseEvent *mouse);
    virtual void mouseReleaseEvent(QMouseEvent *mouse);
    virtual void wheelEvent(QWheelEvent *wheel);
    void timerEvent(QTimerEvent *timer);

public:
    explicit SCustomBallForm(QWidget *parent=0, QPoint initPos=QPoint(-1,-1), QSize initSize=QSize(90,17));
    virtual ~SCustomBallForm();

    virtual void setTargetSize(QSize size);
    virtual void setVisible(bool visible);
    virtual void setColor(QColor color);
    virtual void setAlpha(int alpha);
    bool isCaptured() const {return capt;}
    bool isClosing() const {return closing;}

    SBehavior *Model;

signals:
    void onTimer(QObject *sender);
    void clicked(QObject *sender);
    void pressed(QObject *sender);
    void wheeled(QObject *sender, int wheelDelta);
    void closed();
    void aboutToClose();

private slots:
    void ballSizeReached();

public slots:
    virtual void close();
};

#endif // CSBALLFM_H
